
import $ from 'jquery';

var shopcar = document.querySelector('.shopcar');
var shopcar_menu = document.querySelector('.shopcar-menu');
var loading =  `
<div class="loading-wrapper">
    <div class="loading-1">
        <span></span>
        <span></span>
        <span></span>
    </div>
</div>
    `;
shopcar.addEventListener('mouseenter',function(){
    shopcar_menu.innerHTML = loading;
    setTimeout(()=>{
        $.ajax({
            url:'/api/getShopcar',
            dataType:'json',
            success:function(res) {
                console.log('getShopcar res',res);
                if(res.status !== 'success') {
                    console.log('/api/getShopcar error');
                }
                let data = res.data;
                if(data.count === 0) {
                    shopcar_menu.innerHTML = '购物车还没有商品，赶紧选购吧~';
                    return ;
                }
            }
        });
    },500);
})